import 'package:flutter/material.dart';
import 'package:common_utils/common_utils.dart';

class FirstPage extends StatefulWidget {
  @override
  _FirstPageState createState() => _FirstPageState();
}

class _FirstPageState extends State<FirstPage> {
  TimerUtil mTimerUtil;
  num mTick = 0;
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    mTimerUtil = new TimerUtil(mInterval: 1000, mTotalTime: 5000);

    // 计时回调
    mTimerUtil.setOnTimerTickCallback((int tick) {
      setState(() {
        mTick = tick / 1000;
        print("mTick $mTick");
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
            leading: Icon(Icons.menu),
            title: Text("这是第一个页面"),
            actions: <Widget>[
              Icon(Icons.email),
              Icon(Icons.share),
              Icon(Icons.near_me)
            ]),
        body: Center(
          child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                FlatButton(
                  child: Text('点击进入第二个页面'),
                  onPressed: () {
                    // Navigator.of(context).pushNamed('/');
                  },
                ),
                SizedBox(height: 20),
                OutlineButton(onPressed: () {}, child: Text('点击按钮')),
                SizedBox(height: 20),
                RaisedButton(onPressed: () {}, child: Text('点击按钮'))
              ]),
        ));
  }
}
